AI Verified

Name

Turn grouped product quantities into checkboxes

About

Woocommerce snippet to make quantity input into a checkbox for grouped product with the default one checked

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Add to code snippets if you have Wordfence you will be notified of an issue. This is a false positive and you can add the expection to the hwitelist/allowlist

Codevault

George Snippet Library

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

04/05/2023

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Turn grouped product quantities into checkboxes

 
                    
1function replace_grouped_product_quantity_with_checkbox() {
2 $product = wc_get_product();
3 if ( ! $product || ! $product->is_type( 'grouped' ) ) {
4 return;
5 }
6 ?>
7 <script>
8 jQuery(function($) {
9 $('input.qty').hide().after('<input type="checkbox" class="qty-checkbox" value="1"/>');
10 $('.qty-checkbox').change(function() {
11 $(this).prev('input.qty').val(this.checked ? 1 : 0);
12 });
13 });
14 </script>
15 <?php
16}
17add_action( 'woocommerce_before_add_to_cart_button', 'replace_grouped_product_quantity_with_checkbox' );

0

Related Snippets

Please see some snippets below related to this snippet..

WooCommerce

AI Verified

0

WooCommerce Custom Checkbox Field For The Product Editor

Added: 1 year ago

Last Updated: 1 year ago

This guide shows you how to create a custom checkbox field type in the product editor of WooCommerce. The Sold Individually field is an example checkbox field. A custom checkbox field allows your shop...

WooCommerce

AI Verified

1

WooCommerce Remove Address 2 Checkout Field

Added: 1 year ago

Last Updated: 2 months ago

WooCommerce

AI Verified

0

WooCommerce Add A Fee At Checkout Based On The Postcode Entered

Added: 1 year ago

Last Updated: 1 year ago

You may wish to charge an additional fee based on the user’s postcode. This solution shows how you can add a £5 fee (the currency will be whatever you have set it in your WooCommerce Settings) dependi...

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WooCommerce

AI Verified

6

Delete Woocommerce images after deleting product

Added: 2 years ago

Last Updated: 1 week ago

Automatically Delete WooCommerce Images After Deleting a Product. If you use the same image of multiple products the image will not be deleted for those

WooCommerce

AI Verified

2

Add Alphabetical Sorting to Woocommerce

Added: 2 years ago

Last Updated: 2 months ago

Sorts products alphabetically in Woocommerce

WooCommerce

AI Verified

1

Remove categories from the shop and other pages in Woocommerce

Added: 1 year ago

Last Updated: 1 year ago

Remove any categories from WooCommerce frontend